require('./PageTxHome.less');


import React,{Component,PropTypes} from 'react';
import Reflux from 'reflux';
import ReactMixin from 'react-mixin';
import Actions from './Actions'
import Store from './Store';
import 'weui';
/*import momentLoader from './momentloader.svg';*/
import { Tab,TabBarItem,TabBar,Page,
  Panel,PullToRefresh,CellsTitle,
  PanelHeader,
  PanelBody,
  PanelFooter,
  MediaBox,
  MediaBoxHeader,
  MediaBoxBody,
  MediaBoxTitle,
  MediaBoxDescription,
  MediaBoxInfo,
  MediaBoxInfoMeta,
  Cells,
  Cell,
  CellHeader,
  CellBody,
  CellFooter,
  Flex,Button,
  FlexItem, ActionSheet,
  Grids
} from  'react-weui/build/packages'


import { Control,HashRouter,Route } from 'react-keeper'
import Utils from '../../../utils/index'
import './ptr.less';
import TiXingInfo from '../../../components/txinfo';
const appMsgIcon = <img
  src=""/>


class TxHome extends Component {
  constructor(props) {
    super(props);
    this.state = {
      android_show: false,
      jdrefresh:false,
      menus: [{
        label: '处理',
        onClick: this.popone.bind(this)
      }, {
        label: '查看更多',
        onClick: this.poptwo.bind(this)
      }],
      actions: [
        {
          label: 'Cancel',
          onClick: this.hide.bind(this)
        }
      ]
    };

    this.setSelectInfo = this.setSelectInfo.bind(this);
    this.myRrefresh = this.myRrefresh.bind(this);
    this.loadMore = this.loadMore.bind(this);
  }

  popone(){


  }

  poptwo(){

  }

  hide(){
    this.setState({
      auto_show: false,
      android_show: false,
    });
  }

  loadMore(resolve, finish) {
    this.myRrefresh();
    resolve();
  }


  myRrefresh() {

      Actions.initJDJL();
      this.setState({jdrefresh: false})


  }



  setSelectInfo(obj) {
    this.props.doSomething();
    console.log('返回obj');

    console.info(obj);

    this.setState({android_show: true})
    Actions.onSetCurrentJL(obj);
  }

  render() {
    const t = this;
    return (

      <Page className="page txhome" infiniteLoader={false} ptr={false}  spacing title="Pull To Refresh" subTitle="下拉刷新" >
        <div style={{
          height: '400px',
          background: '#fff'
        }}>
          <ActionSheet
            actions={this.state.actions}
            show={this.state.android_show}
            type="android"
            onRequestClose={e=>this.setState({android_show: false})}
          />

{/*            <ActionSheet
                menus={this.state.menus}
                actions={this.state.actions}
                show={this.state.android_show}
                type="android"
                onRequestClose={e=>this.setState({android_show: false})}
            />*/}

          {/*<div onClick={this.popone}>Click Me</div>*/}
          <PullToRefresh
            onRefresh={this.loadMore}
          >

            <Cells>



                  <div>
                     <TiXingInfo ref="txselect" txls={this.state.txhome.txmap.get("质量问题整改通知书")}   onSelectInfo={this.setSelectInfo}      />
                  </div>



                  <div>
                    <TiXingInfo ref="txselect" txls={this.state.txhome.txmap.get("质量局部暂停施工通知书")}   onSelectInfo={this.setSelectInfo}      />
                  </div>
                  <div>
                    <TiXingInfo ref="txselect" txls={this.state.txhome.txmap.get("安全隐患限期整改通知书")}   onSelectInfo={this.setSelectInfo}      />
                  </div>
                  <div>
                    <TiXingInfo ref="txselect" txls={this.state.txhome.txmap.get("安全隐患局部停工整改通知书")}   onSelectInfo={this.setSelectInfo}      />
                  </div>
                  <div>
                    <TiXingInfo ref="txselect" txls={this.state.txhome.txmap.get("安全隐患责令停工通知书")}   onSelectInfo={this.setSelectInfo}      />
                  </div>

{/*                  <div>
                    <TiXingInfo ref="txselect" txls={this.state.txhome.txmap.get("扬尘处理")}  onSelectInfo={this.setSelectInfo}     />
                  </div>*/}

            </Cells>

          </PullToRefresh>
        </div>
        <br/>

      </Page>

    )
  }


  componentWillMount() {
    Actions.initMode();
  }

  componentDidMount() {
    Actions.initJDJL();
  }


  componentWillReceiveProps(nextProps) {

  }

  shouldComponentUpdate(nextProps, nextState) {
    const thisProps = this.props || {},
      thisState = this.state.txhome || {};
    if (Object.keys(thisProps).length !== Object.keys(nextProps).length ||
      Object.keys(thisState).length !== Object.keys(nextState).length) {
      return true;
    }

    for (const key in nextProps) {
      if (thisProps[key] !== nextProps[key]) {
        console.log(thisProps[key], nextProps[key]);
        return true;
      }
    }

    for (const key in nextState) {
      if (thisState[key] !== nextState[key]) {
        return true;
      }
    }
    return false;
  }

  componentWillUpdate(nextProps, nextState) {

  }


  componentDidUpdate(prevProps, prevState) {

  }


  componentWillUnmount() {

  }
}

TxHome.propTypes = {
  hostUser: React.PropTypes.object.isRequired,
  onSomething: React.PropTypes.func,
}

ReactMixin.onClass(TxHome, Reflux.connect(Store, 'txhome'));


export default TxHome;
